<?php 
	//邮箱验证开始
	if (!empty($_POST['amail'])) {
		$str = $_POST['amail'];
	$preg = "/^[A-z0-9]\w*@[A-z0-9-]+\.[A-z]{2,}(\.[A-z]{2,})*$/";//邮箱正则匹配
	$bool = preg_match($preg, $str);

	if (!$bool) {
		$arr = array(
				'error' => 1,
				'info' => "邮箱格式不符合规则",
			);
		echo json_encode($arr);
		die();
	}
	$db = include_once './save.php';
	foreach ($db as $v) {
		if ($v['sex']==$str) {
			$arr = array(
				'error' => 1,
				'info' => "邮箱存在",
				);
			echo json_encode($arr);
			die();
		}
	}
	$arr = array(
			'error' => 0,
			'info' => '邮箱可以注册'
		);
	echo json_encode($arr);
	}
	//邮箱验证结束
	//昵称开始

	

if (!empty($_POST['anike'])) {
		$str = $_POST['anike'];


	
	$db = include_once './save.php';
	foreach ($db as $v) {
		if ($v['nikename']==$str) {
			$arr = array(
				'error' => 1,
				'info' => "昵称存在",
				);
			echo json_encode($arr);
			die();
		}
	}
	$arr = array(
			'error' => 0,
			'info' => '昵称注册',
		);
	echo json_encode($arr);
	}

//昵称结束
//用户名开始
if (!empty($_POST['auser'])) {
		$str = $_POST['auser'];
	$preg = "/^[A-z]\w{6,8}$/";//用户名正则匹配
	$bool = preg_match($preg, $str);

	if (!$bool) {
		$arr = array(
				'error' => 1,
				'info' => "用户名不符合规则",
			);
		echo json_encode($arr);
		die();
	}
	$db = include_once './save.php';
	foreach ($db as $v) {
		if ($v['username']==$str) {
			$arr = array(
				'error' => 1,
				'info' => "用户名存在",
				);
			echo json_encode($arr);
			die();
		}
	}
	$arr = array(
			'error' => 0,
			'info' => '用户名可以注册',
		);
	echo json_encode($arr);
	}











 ?>